﻿<template>
    <el-dialog title="补录信息" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
        <el-form :model="entityObj" :rules="rules" :disabled="mode == 'Show'" ref="dialogForm" label-width="100px">
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="收货照片">
                        <sc-upload-multiple 
                            v-model="entityObj.taskFiles"
                            :objName="'Supply/TaskFiles'" 
                            :uploadType="'OSS'" 
                            :bucketName="'jtmc'" 
                            :limit="5"
                        />
                        
                    </el-form-item>
                </el-col>
               
            </el-row>
           
            <el-row>
                <el-col :span="24">
                </el-col>
            </el-row>
        </el-form>
        <template #footer>
            <el-button @click="visible = false">取 消</el-button>
            <el-button  type="primary"  :loading="isSaveing"  @click="submit()">提交</el-button>
        </template>
    </el-dialog>
</template>
<script>
import tool from "@/utils/tool";
export default {
    emits: ["success", "closed"],
    data() {
        return {
            mode: "Patch",
            visible: false,
            isSaveing:false,
            titleMap: {
               
            },
            entityObj: {
            },
           
        };
    },
    computed: {
    },
    methods: {
        //显示=
        open(mode = "") {
            console.log("补录");
            this.mode = mode;
            this.visible = true;
            return this;
        },
        //表单注入数据
        async setData(data) {
            this.$nextTick(() => {
                var taskFiles=data.taskFiles?data.taskFiles.join(","):"";
                this.entityObj.taskOrderId=data.taskOrderId;
                this.entityObj.supplierId=data.supplierId;
                this.entityObj.taskFiles=taskFiles;
            });
           
        },
        //提交
        submit() {
            if(this.entityObj.taskOrderId==0)
            {
                if(this.entityObj.taskFiles.includes("blob:")){
                    this.$message.error("图片还未上传成功，请稍后再提交" );
                    return;
                }
                this.$emit("setTaskFile",this.entityObj.taskFiles);
                this.visible = false;
            }else
            {
                this.$refs.dialogForm.validate(async (valid) => {
                    if (valid) {
                        this.isSaveing = true;
                        try {

                            var returnValue =await this.$API.auth.PostProcessApi.post(
                                    "task-order/update-task-item-files",this.entityObj);
                            if (returnValue.status == 200) {
                                this.$message.success("操作成功");
                                this.$emit("fatherMethod");
                                this.isSaveing = false;
                                this.visible = false;
                            } else {
                                this.$message.error("操作失败:" + returnValue.msg);
                                this.isSaveing = false;
                            }
                        } catch (error) {
                            this.loading = false;
                            this.isSaveing = false;
                            return false;
                        }
                    }
                });
            }


           
        }
    },
    async mounted() {
    },
};
</script>

<style scoped>
.el-form-item {
    margin-bottom: 8px !important;
}
</style>
